package com.ruoyi.web.controller.system;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.LmTelemetry;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.service.ILmTelemetryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/admin/telemetry")
public class LmTelemetryController extends BaseController {
    @Autowired
    private ILmTelemetryService telemetryService;

    @GetMapping("/list")
    @ResponseBody
    public TableDataInfo getAdminList(Integer page, Integer limit, String name, Integer status) {
        List<LmTelemetry> adminUserList = telemetryService.getAdminList(page, limit, name,status);
        return getDataTable(adminUserList);
    }
    
    @GetMapping(value = "/detail")
    public AjaxResult getInfo(Integer id) {
        return AjaxResult.success(telemetryService.selectTaskTypeById(id));
    }

    @PostMapping("add")
    public AjaxResult add(LmTelemetry telemetry) {
        telemetry.setCreateTime(new Date());
        telemetry.setDelFlag(0);
        return toAjax(telemetryService.insertTaskType(telemetry));
    }
    
    @PostMapping("edit")
    public AjaxResult edit(LmTelemetry telemetry) {
        telemetry.setUpdateTime(new Date());
        return toAjax(telemetryService.updateTaskType(telemetry));
    }

    @GetMapping("/delete")
    public AjaxResult remove(Integer id) {
        return toAjax(telemetryService.deleteTaskTypeById(id));
    }
}
